package com.fly.snailrun.base.web;


import java.io.Serializable;

/**
 * @author:gaoxu
 * @create:2020-03-20 14:06
 **/
public class ResponseVo<T> implements Serializable {

    private static final long serialVersionUID = 8633104236067134692L;

    private String resCode;
    private String msg;
    private T obj;

    public ResponseVo() {

    }

    public ResponseVo(T data) {
        this.resCode = CommonErrorCode.SYSTEM_SUCCESS.getErrorCode();
        this.obj = data;
    }

    public ResponseVo(String errorCode, String errorMsg) {
        this.resCode = errorCode;
        this.msg = errorMsg;
    }

    public static ResponseVo creComErrorResult(String message) {
        return new ResponseVo(CommonErrorCode.DATA_EMPTY_ERROR.getErrorCode(), message);
    }

    public static ResponseVo creComNetErrorResult() {
        return new ResponseVo(CommonErrorCode.ACCOUNT_EXIST_ERROR.getErrorCode(), CommonErrorCode.ACCOUNT_EXIST_ERROR.getMemo());
    }

    public static ResponseVo creComSucResult() {
        return new ResponseVo(CommonErrorCode.SYSTEM_SUCCESS.getErrorCode(), CommonErrorCode.SYSTEM_SUCCESS.getMemo());
    }

    public static ResponseVo creObjSucResult(String message) {
        return new ResponseVo(CommonErrorCode.SYSTEM_SUCCESS.getErrorCode(), message);
    }

    public String getResCode() {
        return resCode;
    }

    public void setResCode(String resCode) {
        this.resCode = resCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getObj() {
        return obj;
    }

    public void setObj(T obj) {
        this.obj = obj;
    }
}
